<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <img src="images/1.jpg" alt="">
  <button class="btn">1</button>
  <button class="btn">2</button>
  <button class="btn">3</button>
  <button class="btn">4</button>

  <script>
    var oImg = document.querySelector("img");
    var aBtn = document.querySelectorAll(".btn");
    aBtn[0].onclick = function(){
      oImg.src = "images/1.jpg"
    }
    aBtn[1].onclick = function(){
      oImg.src = "images/2.jpg"
    }
    aBtn[2].onclick = function(){
      oImg.src = "images/3.jpg"
    }
    aBtn[3].onclick = function(){
      oImg.src = "images/4.jpg"
    }
  </script>
</body>
</html>